import { defineStore } from 'pinia'

interface User {
  id: string
  name: string
  avatar: string
  email: string
  role: string
}

interface StatData {
  balance: number
  monthlyIncome: number
  pendingTransactions: number
  activeCustomers: number
}

export const useAppStore = defineStore('app', {
  state: () => ({
    user: {
      id: 'u001',
      name: '张经理',
      avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
      email: 'zhang@example.com',
      role: '管理员'
    } as User,
    stats: {
      balance: 4658745.68,
      monthlyIncome: 2000156.0,
      pendingTransactions: 12,
      activeCustomers: 243
    } as StatData,
    sidebarOpen: true
  }),
  actions: {
    toggleSidebar() {
      this.sidebarOpen = !this.sidebarOpen
    },
    updateStats(newStats: Partial<StatData>) {
      this.stats = { ...this.stats, ...newStats }
    }
  }
})